package com.ruan.service.impl;

import com.anji.captcha.service.CaptchaCacheService;
import com.ruan.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName:CaptchaCacheServiceRedisImpl
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/9/21 9:28
 **/
@Service
public class CaptchaCacheServiceRedisImpl implements CaptchaCacheService {


    @Override
    public String type() {
        return "redis";
    }


    @Override
    public void set(String key, String value, long expiresInSeconds) {

        RedisUtil.set(key,value,expiresInSeconds);
    }

    @Override
    public boolean exists(String key) {
        return RedisUtil.hasKey(key);
    }

    @Override
    public void delete(String key) {

        RedisUtil.del(key);
    }

    @Override
    public String get(String key) {
        return (String) RedisUtil.get(key);
    }

    @Override
    public Long increment(String key, long val) {
        return RedisUtil.incr(key,val);
    }
}
